//connessione al database require ("dbconn.inc"); //sessione require ("sessione.inc"); //prendo l'eventuale operazione if (isset($_GET["OP"])) $OP=$_GET["OP"]; else if (isset($_POST["OP"])) $OP=$_POST["OP"]; else $OP=""; //titolo $TITOLO="TeLoRegalo.it, Cancellazione annunci"; echo "
";
//messaggio sotto il titolo
echo "
Strumento per la cancellazione degli annunci dal sito
"; //formatto contenuti echo " ";
if ($OP=="CANC")
{
if (isset($_GET["VAL"])) $VAL=$_GET["VAL"];
else if (isset($_POST["VAL"])) $VAL=$_POST["VAL"];
else $VAL="";
//inizializzo i flag
$flagiderrato=0;
$flagchiaveerrata=0;
//prende i dati per l'attivazione
$IDANNUNCIO=substr($VAL, 0, 10);
$CHIAVE=substr($VAL, 10, 8);
$q="select * from annunci where (idannuncio='$IDANNUNCIO' AND stato='AT')";
//echo "Query in pubblica: $q "; $ri=mysql_db_query($database,$q,$id) or die(mysql_error()); $nr=mysql_num_rows($ri); //echo "Ottengo $nr risultati "; //nessun goal if ($nr!=1) $flagiderrato=1; else { $r=mysql_fetch_array($ri); //confronto le chiavi //echo "Chiave privata: ".$r["chiave"]." "; //echo "Chiave passata: ".$CHIAVE." "; if ($CHIAVE<>$r["chiave"]) $flagchiaveerrata=1; } if ($flagiderrato || $flagchiaveerrata) { echo " CANCELLAZIONE NON ESEGUITAATTENZIONE! L'annuncio non è stato cancellato per il seguente motivo: "; if ($flagiderrato==1) echo "- L'annuncio è inesistente oppure è stato già cancellato."; if ($flagchiaveerrata==1) echo "- Il codice di cancellazione dell'annuncio è errato."; echo " Riprova - Home Page"; } else { //prende data, ora e IP remoto $timestamp=date("Y-m-d")." ".date("H:i:s"); $REMOTE_ADDR=$_SERVER["REMOTE_ADDR"]; //aggiorna il record $q="update annunci set stato='CA', datacanc='$timestamp', ipcanc='$REMOTE_ADDR' where idannuncio='$IDANNUNCIO'"; $ri=mysql_db_query($database,$q,$id) or die(mysql_error()); //copio il record nella tabella dei cancellati $q="INSERT INTO annunci_cancellati SELECT * FROM annunci WHERE idannuncio='$IDANNUNCIO'"; $ri=mysql_db_query($database,$q,$id) or die(mysql_error()); //cancello il record dalla tabella originale $q="DELETE FROM annunci WHERE idannuncio='$IDANNUNCIO'"; $ri=mysql_db_query($database,$q,$id) or die(mysql_error()); echo "
L'annuncio è stato cancellato correttamente.
CONFERMA DI CANCELLAZIONE ANNUNCIO |
TeLoRegalo.it è un servizio di Officine Informatiche Srl P.IVA 01928990603 - Note legali
"; //chiudo il center echo "